package com.szzg10.pattern.state;

public class Machine {

	private int count;
	private State state;
	
	private State noCoinState;
	private State coinState;
	private State outSugerState;
	private State soldOutState;
	
	public Machine(int count) {
		this.count = count;
		
		noCoinState = new NoCoinState(this);
		coinState = new CoinState(this);
		outSugerState = new OutSugerState(this);
		soldOutState = new SoldOutState(this);
		
		state = noCoinState;
	}
	
	public void insert() {
		state.insert();
	}
	
	public void refund() {
		state.refund();
	}
	
	public void turn() {
		state.turn();
	}
	
	public void release() {
		state.out();
	}
	
	//---getter and setter---
	public State getState() {
		return state;
	}

	public void setState(State state) {
		this.state = state;
	}

	public State getNoCoinState() {
		return noCoinState;
	}

	public void setNoCoinState(State noCoinState) {
		this.noCoinState = noCoinState;
	}

	public State getCoinState() {
		return coinState;
	}

	public void setCoinState(State coinState) {
		this.coinState = coinState;
	}

	public State getOutSugerState() {
		return outSugerState;
	}

	public void setOutSugerState(State outSugerState) {
		this.outSugerState = outSugerState;
	}

	public State getSoldOutState() {
		return soldOutState;
	}

	public void setSoldOutState(State soldOutState) {
		this.soldOutState = soldOutState;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}
	
}
